WITH c([object_id], [max_length]) AS
(
SELECT [object_id], [max_length]
FROM sys.columns c
WHERE c.system_type_id=167 and max_length<40
)
SELECT s.name + N'.' + t.name AS [TableName], c.[max_length] AS [Len]
FROM c
INNER JOIN sys.tables AS t ON c.[object_id] = t.[object_id]
INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id]
(
SELECT [object_id], [max_length]
FROM sys.columns c
WHERE c.system_type_id=167 and max_length<40
)
SELECT s.name + N'.' + t.name AS [TableName], c.[max_length] AS [Len]
FROM c
INNER JOIN sys.tables AS t ON c.[object_id] = t.[object_id]
INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id]
برای اطلاع از انواع داده ها نیز می توانید از دستور زیر استفاده کنید:
SELECT * FROM sys.types